<div id="required_fields_message"><?php echo $this->lang->line('common_fields_required_message'); ?></div>
<ul id="error_message_box"></ul>
<?php
$save_category_id=($category->category_id==''?'-1':$category->category_id);
echo form_open('items/save_category/'.$save_category_id,array('id'=>'category_form'));
?>
<fieldset id="item_basic_info">
<legend><?php echo $this->lang->line("categories_categories"); ?></legend>

<div class="field_row clearfix">
<?php echo form_label($this->lang->line('categories_id').':', 'category_id',array('class'=>'required wide')); ?>
	<div class='form_field'>
	<?php 
	if ($category->category_id=='') {
		echo form_input(array(
			'name'=>'category_id',
			'id'=>'category_id',
			'value'=>$category->category_id)
			);
	} else {
		echo form_input(array(
			'name'=>'category_id',
			'id'=>'category_id',
			'value'=>$category->category_id,
			'readonly'=>'readonly')
			);
	}
	?>
	</div>
</div>	

<div class="field_row clearfix">
<?php echo form_label($this->lang->line('categories_name').':', 'category_name',array('class'=>'required wide')); ?>
	<div class='form_field'>
	<?php echo form_input(array(
		'name'=>'category_name',
		'id'=>'category_name',
		'value'=>$category->category_name)
	);?>
	</div>
</div>

<div class="field_row clearfix">
<?php echo form_label($this->lang->line('categories_name_en').':', 'category_name_en',array('class'=>'required wide')); ?>
	<div class='form_field'>
	<?php echo form_input(array(
		'name'=>'category_name_en',
		'id'=>'category_name_en',
		'value'=>$category->category_name_en)
	);?>
	</div>
</div>


<div class="field_row clearfix">
<?php echo form_label($this->lang->line('categories_labour_cost').':', 'labour_cost',array('class'=>'required wide')); ?>
	<div class='form_field'>
	<?php echo form_input(array(
		'name'=>'labour_cost',
		'id'=>'labour_cost',
		'value'=>$category->labour_cost)
	);?>
	</div>
</div>
<div class="field_row clearfix">

<?php
echo form_reset(array(
	'name'=>'reset',
	'id'=>'reset',
	'value'=>$this->lang->line('common_reset'),
	'class'=>'submit_button float_right')
);
?>

<?php
echo form_submit(array(
	'name'=>'submit',
	'id'=>'submit',
	'value'=>$this->lang->line('common_submit'),
	'class'=>'submit_button float_right')
);
?>

</fieldset>
<?php
echo form_close();
?>
<script type='text/javascript'>

//validation and submit handling
$(document).ready(function()
{

	$('#category_form').validate({
		submitHandler:function(form)
		{
			$(form).ajaxSubmit({
			success:function(response)
			{
				tb_remove();
				post_item_form_submit(response);
			},
			dataType:'json'
		});
        
		},
		errorLabelContainer: "#error_message_box",
 		//wrapper: "li",
		rules:
		{
			category_id:
			{
				required:true,
				number:true
			},
			category_name:"required",
			category_name_en:"required",
			labour_cost:
			{
				required:true,
				number:true
			}
   		},
		messages:
		{
			
			category_id:
			{
				required:"<?php echo $this->lang->line('categories_category_id_required'); ?>",
				number:"<?php echo $this->lang->line('categories_category_id_number'); ?>"
			},
			category_name:"<?php echo $this->lang->line('categories_name_required'); ?>",
			category_name_en:"<?php echo $this->lang->line('categories_name_en_required'); ?>",
			labour_cost:
			{
				required:"<?php echo $this->lang->line('categories_labour_cost_required'); ?>",
				number:"<?php echo $this->lang->line('categories_labour_cost_number'); ?>"
			},
			
		}
	});
});
</script>